home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / info-service / gopher / Unix / xvgopher / v0.5beta / xvgopher.shar.03 < prev    next >
Encoding:
Text File  |  1993-03-26  |  53.3 KB  |  2,335 lines

  1. ---- Cut Here and feed the following to sh ----
  2. #!/bin/sh
  3. # This is part 03 of a multipart archive
  4. # ============= Gopher.cc ==============
  5. if test -f 'Gopher.cc' -a X"$1" != X"-c"; then
  6.     echo 'x - skipping Gopher.cc (File already exists)'
  7. else
  8. echo 'x - extracting Gopher.cc (Text)'
  9. sed 's/^X//' << 'SHAR_EOF' > 'Gopher.cc' &&
  10. //
  11. // Gopher.cc
  12. //
  13. // (c) Copyright 1993, San Diego State University -- College of Sciences
  14. //       (See the COPYRIGHT file for more Copyright information)
  15. //
  16. // Implementation of the Gopher class
  17. //
  18. #include "Gopher.h"
  19. #include "String.h"
  20. #include "Connection.h"
  21. #include "GWindow.h"
  22. #include "Response.h"
  23. #include <unistd.h>
  24. #include <stdio.h>
  25. #include <xview/notify.h>
  26. #include <fcntl.h>
  27. #include <time.h>
  28. X
  29. #define    LINE_COUNT_INCREMENT    20
  30. #define    MAX_LIST_LINES            1023
  31. X
  32. X
  33. //***************************************************************************
  34. // Gopher::Gopher(GWindow *gwin)
  35. //
  36. Gopher::Gopher(GWindow *gwin)
  37. {
  38. X    fd = -1;
  39. X    gwindow = gwin;
  40. X    *filename = '\0';
  41. X    connection = (Connection *) 0;
  42. }
  43. X
  44. X
  45. //***************************************************************************
  46. // Gopher::~Gopher()
  47. //
  48. Gopher::~Gopher()
  49. {
  50. X    if (connection->isopen())
  51. X        (void) notify_set_input_func((Notify_client) this, NOTIFY_FUNC_NULL, connection->get_socket());
  52. X    fd = -1;
  53. X    if (*filename)
  54. X        unlink(filename);
  55. X    if (connection)
  56. X        delete connection;
  57. }
  58. X
  59. X
  60. //***************************************************************************
  61. // Gopher::Gopher(char *server, int port, GWindow *gwin)
  62. //
  63. Gopher::Gopher(char *server, int port, GWindow *gwin)
  64. {
  65. X    fd = -1;
  66. X    gwindow = gwin;
  67. X    *filename = '\0';
  68. X    if (open(server, port) == NOTOK)
  69. X        exit(1);
  70. }
  71. X
  72. X
  73. //***************************************************************************
  74. // int Gopher::open(server, port)
  75. // PURPOSE:
  76. //    Build a connection with the gopher server.
  77. //
  78. int Gopher::open(char *server, int port)
  79. {
  80. X    connection = new Connection;
  81. X
  82. X    if (connection->open() == NOTOK)
  83. X        return NOTOK;
  84. X    if (connection->assign_port(port) == NOTOK)
  85. X        return NOTOK;
  86. X    if (connection->assign_server(server) == NOTOK)
  87. X        return NOTOK;
  88. X    if (connection->connect() == NOTOK)
  89. X        return NOTOK;
  90. X
  91. X    return OK;
  92. }
  93. X
  94. X
  95. //***************************************************************************
  96. // int Gopher::read(char type, char *cmd)
  97. // PURPOSE:
  98. //    Send cmd to the server and receive the information until the
  99. //    connection is closed by the server
  100. //
  101. int Gopher::read(char type, char *cmd)
  102. {
  103. X    gwindow->status("Retrieving information...");
  104. X
  105. X    //
  106. X    // First send the command.  We need to terminate the command with
  107. X    // a return.  Since we do not know how big cmd is, we will just make
  108. X    // it into two writes.
  109. X    //
  110. X    if (cmd == NULL)
  111. X        cmd = "";
  112. X    connection->write(cmd, strlen(cmd));
  113. X    connection->write("\r\n", 2);
  114. X
  115. X    //
  116. X    // Now we are ready to receive the information.  The type of information
  117. X    // depends on the command we sent to the server, so we will use it
  118. X    // to determine where this information will be stored.
  119. X    //
  120. X    switch (type)
  121. X    {
  122. X        case GOPHER_FILE:
  123. X            //
  124. X            // Plain ASCII file coming through...  Save it someplace
  125. X            //
  126. X            read_ascii();
  127. X            break;
  128. X        case GOPHER_DIRECTORY:
  129. X        case '\0':
  130. X            //
  131. X            // We are getting a directory listing.  Read it into our List
  132. X            //
  133. X            read_list();
  134. X            break;
  135. X        case GOPHER_CSO:
  136. X            break;
  137. X        case GOPHER_ERROR:
  138. X            break;
  139. X        case GOPHER_UU:
  140. X            break;
  141. X        case GOPHER_INDEX:
  142. X            break;
  143. X        case GOPHER_TELNET:
  144. X            break;
  145. X        case GOPHER_BINHEX:
  146. X        case GOPHER_DOS:
  147. X        case GOPHER_BIN:
  148. X            //
  149. X            // Some binary file coming in.  Read until connection closes
  150. X            //
  151. X            read_binary();
  152. X            break;
  153. X        case GOPHER_SOUND:
  154. X            //
  155. X            // Some binary file coming in.  Read until connection closes
  156. X            //
  157. X            read_binary();
  158. X            datatype = TYPE_SOUND;
  159. X            break;
  160. X        case GOPHER_IMAGE:
  161. X        case GOPHER_GIF:
  162. X            //
  163. X            // Some binary file coming in.  Read until connection closes
  164. X            //
  165. X            read_binary();
  166. X            datatype = TYPE_IMAGE;
  167. X            break;
  168. X        case GOPHER_REDUNDANT:
  169. X            break;
  170. X        default:
  171. X            printf("Hmm.  The I don't know how to read data of type '%c'\n", type);
  172. X            break;
  173. X    }
  174. X    return OK;
  175. }
  176. X
  177. X
  178. //***************************************************************************
  179. // void Gopher::start_get()
  180. // PURPOSE:
  181. //    Set up the list of data so we can retrieve data in order
  182. //
  183. void Gopher::start_get()
  184. {
  185. X    list.start_get();
  186. }
  187. X
  188. X
  189. //***************************************************************************
  190. // char *Gopher::get_next()
  191. // PURPOSE:
  192. //    Get the next item from our list
  193. //
  194. char *Gopher::get_next()
  195. {
  196. X    String    *str = (String *) list.get_next();
  197. X
  198. X    if (str)
  199. X        return str->get();
  200. X    else
  201. X        return NULL;
  202. }
  203. X
  204. X
  205. //***************************************************************************
  206. // void Gopher::read_list()
  207. //
  208. void Gopher::read_list()
  209. {
  210. X    //
  211. X    // In order not to block on a read, we will use the xview read notify
  212. X    // to tell us when data is actually available.
  213. X    //
  214. X    datatype = TYPE_LIST;
  215. X    length = 0;
  216. X    (void) notify_set_input_func((Notify_client) this, (Notify_func) read_list_proc, connection->get_socket());
  217. }
  218. X
  219. #define    INPUT_BUF_SIZE    50000
  220. X
  221. //***************************************************************************
  222. // void Gopher::read_list_proc(Gopher *gopher, int ifd)
  223. //
  224. void Gopher::read_list_proc(Gopher *gopher, int ifd)
  225. {
  226. X    char            buffer[INPUT_BUF_SIZE];
  227. X    static time_t    last = 0;
  228. X    char            *p;
  229. X
  230. X    if (gopher->connection->read_line(buffer, INPUT_BUF_SIZE) == NULL || gopher->length > MAX_LIST_LINES)
  231. X    {
  232. X        //
  233. X        // End of file reached.
  234. X        //
  235. X        (void) notify_set_input_func((Notify_client) gopher, NOTIFY_FUNC_NULL, ifd);
  236. X        gopher->connection->close();
  237. X        gopher->gwindow->display();
  238. X        sprintf(buffer, "Total of %d item%s", gopher->length, gopher->length == 1 ? "" : "s");
  239. X        gopher->gwindow->status(buffer);
  240. X
  241. X        if (gopher->length == 0)
  242. X        {
  243. X            //
  244. X            // Nothing was found.  Let the user know...
  245. X            //
  246. X            gopher->gwindow->nothing_found();
  247. X        }
  248. X    }
  249. X    else
  250. X    {
  251. X        if (*buffer == '.' && buffer[1] == '\0')
  252. X            return;
  253. X        p = buffer;
  254. X        while (*p == '-' || *p > 126 || *p < 32)
  255. X            p++;
  256. X        gopher->list.add(new String(p));
  257. X
  258. X        //
  259. X        // Keep a running count and display the results every second
  260. X        //
  261. X        gopher->length++;
  262. X        if (gopher->length > MAX_LIST_LINES)
  263. X            gopher->gwindow->list_full();
  264. X
  265. X        if (last < time(NULL))
  266. X        {
  267. X            char str[20];
  268. X            sprintf(str, "%d line%s...", gopher->length, gopher->length == 1 ? "" : "s");
  269. X            gopher->gwindow->status(str);
  270. X            last = time(NULL);
  271. X        }
  272. X    }
  273. }
  274. X
  275. X
  276. //***************************************************************************
  277. // void Gopher::read_ascii()
  278. //
  279. void Gopher::read_ascii()
  280. {
  281. X    datatype = TYPE_ASCII;
  282. X    strcpy(filename, "/tmp/gophXXXXXX");
  283. X    fd = mkstemp(filename);
  284. X    length = 0;
  285. X    (void) notify_set_input_func((Notify_client) this, (Notify_func) read_ascii_proc, connection->get_socket());
  286. }
  287. X
  288. X
  289. //***************************************************************************
  290. // void Gopher::read_ascii_proc(Gopher *gopher, int ifd)
  291. //
  292. void Gopher::read_ascii_proc(Gopher *gopher, int ifd)
  293. {
  294. X    char            buffer[INPUT_BUF_SIZE];
  295. X    static time_t    last = 0;
  296. X
  297. X    if (gopher->connection->read_line(buffer, INPUT_BUF_SIZE) == NULL)
  298. X    {
  299. X        //
  300. X        // End of file reached.
  301. X        //
  302. X        ::close(gopher->fd);
  303. X        (void) notify_set_input_func((Notify_client) gopher, NOTIFY_FUNC_NULL, ifd);
  304. X        gopher->connection->close();
  305. X        gopher->gwindow->display();
  306. X        char str[30];
  307. X        sprintf(str, "Total of %d lines", gopher->length);
  308. X        gopher->gwindow->status(str);
  309. X    }
  310. X    else
  311. X    {
  312. X        if (*buffer == '.' && buffer[1] == '\0')
  313. X            return;
  314. X        write(gopher->fd, buffer, strlen(buffer));
  315. X        write(gopher->fd, "\n", 1);
  316. X        gopher->length++;
  317. X        if (last < time(NULL))
  318. X        {
  319. X            char str[20];
  320. X            sprintf(str, "%d line%s...", gopher->length, gopher->length == 1 ? "" : "s");
  321. X            gopher->gwindow->status(str);
  322. X            last = time(NULL);
  323. X        }
  324. X    }
  325. }
  326. X
  327. X
  328. //***************************************************************************
  329. // void Gopher::read_binary()
  330. //
  331. void Gopher::read_binary()
  332. {
  333. X    datatype = TYPE_BINARY;
  334. X    strcpy(filename, "/tmp/gophXXXXXX");
  335. X    fd = mkstemp(filename);
  336. X    length = 0;
  337. X    gwindow->status("Waiting for first data to arrive...");
  338. X    (void) notify_set_input_func((Notify_client) this, (Notify_func) read_binary_proc, connection->get_socket());
  339. }
  340. X
  341. X
  342. //***************************************************************************
  343. // void Gopher::read_binary_proc(Gopher *gopher, int ifd)
  344. //
  345. void Gopher::read_binary_proc(Gopher *gopher, int ifd)
  346. {
  347. X    char            buffer[INPUT_BUF_SIZE];
  348. X    static time_t    last = 0;
  349. X
  350. X    int n = gopher->connection->read_partial(buffer, INPUT_BUF_SIZE);
  351. X    if (n <= 0)
  352. X    {
  353. X        //
  354. X        // End of file reached.
  355. X        //
  356. X        ::close(gopher->fd);
  357. X        (void) notify_set_input_func((Notify_client) gopher, NOTIFY_FUNC_NULL, ifd);
  358. X        gopher->connection->close();
  359. X        gopher->gwindow->display();
  360. X        sprintf(buffer, "Total of %d bytes", gopher->length);
  361. X        gopher->gwindow->status(buffer);
  362. X    }
  363. X    else
  364. X    {
  365. X        ::write(gopher->fd, buffer, n);
  366. X        gopher->length += n;
  367. X        if (last < time(NULL))
  368. X        {
  369. X            char status[40];
  370. X            sprintf(status, "%d byte%s...", gopher->length, gopher->length == 1 ? "" : "s");
  371. X            gopher->gwindow->status(status);
  372. X            last = time(NULL);
  373. X        }
  374. X    }
  375. }
  376. X
  377. X
  378. SHAR_EOF
  379. chmod 0664 Gopher.cc ||
  380. echo 'restore of Gopher.cc failed'
  381. Wc_c="`wc -c < 'Gopher.cc'`"
  382. test 8621 -eq "$Wc_c" ||
  383.     echo 'Gopher.cc: original size 8621, current size' "$Wc_c"
  384. fi
  385. # ============= List.cc ==============
  386. if test -f 'List.cc' -a X"$1" != X"-c"; then
  387.     echo 'x - skipping List.cc (File already exists)'
  388. else
  389. echo 'x - extracting List.cc (Text)'
  390. sed 's/^X//' << 'SHAR_EOF' > 'List.cc' &&
  391. //
  392. // List.cc
  393. //
  394. // (c) Copyright 1993, San Diego State University -- College of Sciences
  395. //       (See the COPYRIGHT file for more Copyright information)
  396. //
  397. // Implementation of the List class
  398. //
  399. #include "List.h"
  400. X
  401. #define    NULL    ((void *) 0)
  402. X
  403. X
  404. //***************************************************************************
  405. // List::List()
  406. //
  407. List::List()
  408. {
  409. X    first = last = current = (Object *) 0;
  410. X    size = 0;
  411. }
  412. X
  413. X
  414. //***************************************************************************
  415. // List::~List()
  416. //
  417. List::~List()
  418. {
  419. X    if (first)
  420. X    {
  421. X        Object    *obj;
  422. X        start_get();
  423. X        while (obj = get_next())
  424. X        {
  425. X            delete obj;
  426. X        }
  427. X    }
  428. }
  429. X
  430. X
  431. //***************************************************************************
  432. // void List::add(Object *obj)
  433. // PURPOSE:
  434. //    Add an object to the list.  The adding will be done at the end of the
  435. //    list.
  436. void List::add(Object *obj)
  437. {
  438. X    if (!first)
  439. X    {
  440. X        //
  441. X        // The list is empty.  Easy!  Just put the object in it.
  442. X        //
  443. X        first = last = obj;
  444. X        obj->Next((Object *) 0);
  445. X        obj->Previous((Object *) 0);
  446. X    }
  447. X    else
  448. X    {
  449. X        //
  450. X        // There is something already in the list.  Just append it
  451. X        //
  452. X        last->Next(obj);
  453. X        obj->Previous(last);
  454. X        obj->Next((Object *) 0);
  455. X        last = obj;
  456. X    }
  457. X    size++;
  458. }
  459. X
  460. X
  461. //***************************************************************************
  462. // void List::start_get()
  463. // PURPOSE:
  464. //    Prepare the list for itteration.  This needs to be called so that
  465. //    get_next() will return the first element of the list
  466. //
  467. void List::start_get()
  468. {
  469. X    current = first;
  470. }
  471. X
  472. X
  473. //***************************************************************************
  474. // Object *List::get_next()
  475. // PURPOSE:
  476. //    Return the next object in the list
  477. //
  478. Object *List::get_next()
  479. {
  480. X    if (current)
  481. X    {
  482. X        Object    *temp = current;
  483. X        current = current->Next();
  484. X        return temp;
  485. X    }
  486. X    else
  487. X        return (Object *) 0;
  488. }
  489. X
  490. SHAR_EOF
  491. chmod 0644 List.cc ||
  492. echo 'restore of List.cc failed'
  493. Wc_c="`wc -c < 'List.cc'`"
  494. test 1821 -eq "$Wc_c" ||
  495.     echo 'List.cc: original size 1821, current size' "$Wc_c"
  496. fi
  497. # ============= Preferences.cc ==============
  498. if test -f 'Preferences.cc' -a X"$1" != X"-c"; then
  499.     echo 'x - skipping Preferences.cc (File already exists)'
  500. else
  501. echo 'x - extracting Preferences.cc (Text)'
  502. sed 's/^X//' << 'SHAR_EOF' > 'Preferences.cc' &&
  503. //
  504. // Preferences.cc
  505. //
  506. // (c) Copyright 1993, San Diego State University -- College of Sciences
  507. //       (See the COPYRIGHT file for more Copyright information)
  508. //
  509. // Implementation of the Preferences class
  510. //
  511. #include "Preferences.h"
  512. #include "xvgopher.h"
  513. #include <stdlib.h>
  514. #include <fstream.h>
  515. #include <xview/xview.h>
  516. #include <xview/defaults.h>
  517. X
  518. X
  519. //***************************************************************************
  520. // Preferences::Preferences()
  521. //
  522. Preferences::Preferences()
  523. {
  524. X    //
  525. X    // Get the path to the .xvgopher-defaults file in the user's home directory
  526. X    //
  527. X    char        *home = getenv("HOME");
  528. X    if (!home)
  529. X        home = ".";
  530. X    char        filename[100];
  531. X    sprintf(filename, "%s/.xvgopher-defaults", home);
  532. X
  533. X    //
  534. X    // Read in any values from it
  535. X    //
  536. X    defaults_load_db(filename);
  537. X
  538. X    //
  539. X    // Now get the values we are interested in.
  540. X    //
  541. X    remove_children = defaults_get_boolean("xvgopher.removeclients", "XvGopher.RemoveClients", FALSE);
  542. X    popup_bookmarks = defaults_get_boolean("xvgopher.popupbookmarks", "XvGopher.PopupBookmarks", FALSE);
  543. X    mail_filter = strdup(defaults_get_string("xvgopher.mailfilter", "XvGopher.MailFilter", DEFAULT_MAILER));
  544. X    print_filter = strdup(defaults_get_string("xvgopher.printfilter", "XvGopher.PrintFilter", DEFAULT_PRINT_FILTER));
  545. X    play_filter = strdup(defaults_get_string("xvgopher.playfilter", "XvGopher.PlayFilter", DEFAULT_PLAYER));
  546. X    image_filter = strdup(defaults_get_string("xvgopher.imagefilter", "XvGopher.ImageFilter", DEFAULT_IMAGER));
  547. X    telnet_command = strdup(defaults_get_string("xvgopher.telnetcommand", "XvGopher.TelnetCommand", DEFAULT_TELNET));
  548. }
  549. X
  550. X
  551. //***************************************************************************
  552. // Preferences::~Preferences()
  553. //
  554. Preferences::~Preferences()
  555. {
  556. X    //
  557. X    // Get the path to the .xvgopher-defaults file in the user's home directory
  558. X    //
  559. X    char        *home = getenv("HOME");
  560. X    if (!home)
  561. X        home = ".";
  562. X    char        filename[100];
  563. X    sprintf(filename, "%s/.xvgopher-defaults", home);
  564. X
  565. X    ofstream    out(filename);
  566. X    if (out.fail())
  567. X        return;
  568. X
  569. X    static char *truth[2] = {"False", "True"};
  570. X
  571. X    //
  572. X    // Write the things we know about to the file
  573. X    //
  574. X    out << "XvGopher.RemoveClients:\t" << truth[remove_children] << "\n";
  575. X    out << "XvGopher.PopupBookmarks:\t" << truth[popup_bookmarks] << "\n";
  576. X    out << "XvGopher.MailFilter:\t" << mail_filter << "\n";
  577. X    out << "XvGopher.PrintFilter:\t" << print_filter << "\n";
  578. X    out << "XvGopher.PlayFilter:\t" << play_filter << "\n";
  579. X    out << "XvGopher.ImageFilter:\t" << image_filter << "\n";
  580. X    out << "XvGopher.TelnetCommand:\t" << telnet_command << "\n";
  581. X    out.close();
  582. X
  583. X    //
  584. X    // For good measures, we should delete the storage used by the preferences
  585. X    //
  586. X    delete mail_filter;
  587. X    delete print_filter;
  588. X    delete play_filter;
  589. X    delete image_filter;
  590. X    delete telnet_command;
  591. }
  592. X
  593. X
  594. //***************************************************************************
  595. // int Preferences::get_remove_children()
  596. //
  597. int Preferences::get_remove_children()
  598. {
  599. X    return remove_children;
  600. }
  601. X
  602. X
  603. //***************************************************************************
  604. // void Preferences::set_remove_children(int x)
  605. //
  606. void Preferences::set_remove_children(int x)
  607. {
  608. X     remove_children = x != 0;
  609. }
  610. X
  611. X
  612. //***************************************************************************
  613. // int Preferences::get_popup_bookmarks()
  614. //
  615. int Preferences::get_popup_bookmarks()
  616. {
  617. X    return popup_bookmarks;
  618. }
  619. X
  620. X
  621. //***************************************************************************
  622. // void Preferences::set_popup_bookmarks(int x)
  623. //
  624. void Preferences::set_popup_bookmarks(int x)
  625. {
  626. X     popup_bookmarks = x != 0;
  627. }
  628. X
  629. X
  630. //***************************************************************************
  631. // char *Preferences::get_mail_filter()
  632. //
  633. char *Preferences::get_mail_filter()
  634. {
  635. X    return mail_filter;
  636. }
  637. X
  638. X
  639. //***************************************************************************
  640. // void Preferences::set_mail_filter(char *s)
  641. //
  642. void Preferences::set_mail_filter(char *s)
  643. {
  644. X    delete mail_filter;
  645. X     mail_filter = strdup(s);
  646. }
  647. X
  648. X
  649. //***************************************************************************
  650. // char *Preferences::get_print_filter()
  651. //
  652. char *Preferences::get_print_filter()
  653. {
  654. X    return print_filter;
  655. }
  656. X
  657. X
  658. //***************************************************************************
  659. // void Preferences::set_print_filter(char *s)
  660. //
  661. void Preferences::set_print_filter(char *s)
  662. {
  663. X    delete print_filter;
  664. X     print_filter = strdup(s);
  665. }
  666. X
  667. X
  668. //***************************************************************************
  669. // char *Preferences::get_play_filter()
  670. //
  671. char *Preferences::get_play_filter()
  672. {
  673. X    return play_filter;
  674. }
  675. X
  676. X
  677. //***************************************************************************
  678. // void Preferences::set_play_filter(char *s)
  679. //
  680. void Preferences::set_play_filter(char *s)
  681. {
  682. X    delete play_filter;
  683. X     play_filter = strdup(s);
  684. }
  685. X
  686. X
  687. //***************************************************************************
  688. // char *Preferences::get_image_filter()
  689. //
  690. char *Preferences::get_image_filter()
  691. {
  692. X    return image_filter;
  693. }
  694. X
  695. X
  696. //***************************************************************************
  697. // void Preferences::set_image_filter(char *s)
  698. //
  699. void Preferences::set_image_filter(char *s)
  700. {
  701. X    delete image_filter;
  702. X     image_filter = strdup(s);
  703. }
  704. X
  705. X
  706. //***************************************************************************
  707. // char *Preferences::get_telnet_command()
  708. //
  709. char *Preferences::get_telnet_command()
  710. {
  711. X    return telnet_command;
  712. }
  713. X
  714. X
  715. //***************************************************************************
  716. // void Preferences::set_telnet_command(char *s)
  717. //
  718. void Preferences::set_telnet_command(char *s)
  719. {
  720. X    delete telnet_command;
  721. X    telnet_command = strdup(s);
  722. }
  723. X
  724. X
  725. SHAR_EOF
  726. chmod 0664 Preferences.cc ||
  727. echo 'restore of Preferences.cc failed'
  728. Wc_c="`wc -c < 'Preferences.cc'`"
  729. test 5632 -eq "$Wc_c" ||
  730.     echo 'Preferences.cc: original size 5632, current size' "$Wc_c"
  731. fi
  732. # ============= Response.cc ==============
  733. if test -f 'Response.cc' -a X"$1" != X"-c"; then
  734.     echo 'x - skipping Response.cc (File already exists)'
  735. else
  736. echo 'x - extracting Response.cc (Text)'
  737. sed 's/^X//' << 'SHAR_EOF' > 'Response.cc' &&
  738. //
  739. // Response.cc
  740. //
  741. // (c) Copyright 1993, San Diego State University -- College of Sciences
  742. //       (See the COPYRIGHT file for more Copyright information)
  743. //
  744. // Implementation of the Response class
  745. //
  746. #include "Response.h"
  747. #include <string.h>
  748. #include <stdio.h>
  749. X
  750. X
  751. //***************************************************************************
  752. // Response::Response()
  753. //
  754. Response::Response()
  755. {
  756. X    words[0] = NULL;
  757. X    wordcount = 0;
  758. }
  759. X
  760. X
  761. //***************************************************************************
  762. // Response::Response(Response *r)
  763. //
  764. Response::Response(Response *r)
  765. {
  766. X    for (wordcount = 0; wordcount < r->wordcount; wordcount++)
  767. X        words[wordcount] = strdup(r->words[wordcount]);
  768. X    type = r->type;
  769. }
  770. X
  771. X
  772. //***************************************************************************
  773. // Response::Response(char *str)
  774. //
  775. Response::Response(char *str)
  776. {
  777. X    words[0] = NULL;
  778. X    wordcount = 0;
  779. X
  780. X    set(str);
  781. }
  782. X
  783. X
  784. //***************************************************************************
  785. // Response::~Response()
  786. //
  787. Response::~Response()
  788. {
  789. X    for (int i = 0; i < wordcount; i++)
  790. X        if (words[i])
  791. X            delete words[i];
  792. }
  793. X
  794. X
  795. //***************************************************************************
  796. // int Response::set(char *str)
  797. //
  798. int Response::set(char *str)
  799. {
  800. X    extern char *good_strtok(char *, char *);
  801. X    char    *temp = strdup(str);
  802. X
  803. X    type = *temp;
  804. X    char *token = good_strtok(temp + 1, "\t\r\n");
  805. X    if (!token)
  806. X    {
  807. X        delete temp;
  808. X        return 0;
  809. X    }
  810. X    words[0] = strdup(token);
  811. X    for (wordcount = 1; (token = good_strtok((char *) 0, "\t\r\n")); wordcount++)
  812. X        words[wordcount] = strdup(token);
  813. X    delete temp;
  814. X    return wordcount;
  815. }
  816. X
  817. X
  818. //***************************************************************************
  819. // char *Response::get_nth(int n)
  820. //
  821. char *Response::get_nth(int n)
  822. {
  823. X    if (n >= wordcount || n < 0)
  824. X        return (char *) 0;
  825. X    else
  826. X        return words[n];
  827. }
  828. X
  829. X
  830. //***************************************************************************
  831. // void Response::set_nth(int n, char *str)
  832. //
  833. void Response::set_nth(int n, char *str)
  834. {
  835. X    if (n >= MAX_WORDS || n < 0)
  836. X        return;
  837. X    else
  838. X    {
  839. X        words[n] = strdup(str);
  840. X        if (n >= wordcount)
  841. X            wordcount = n + 1;
  842. X    }
  843. }
  844. X
  845. X
  846. //***************************************************************************
  847. // void Response::set_nth(int n, int x)
  848. //
  849. void Response::set_nth(int n, int x)
  850. {
  851. X    if (n >= MAX_WORDS || n < 0)
  852. X        return;
  853. X    else
  854. X    {
  855. X        char buffer[20];
  856. X        sprintf(buffer, "%d", x);
  857. X        words[n] = strdup(buffer);
  858. X        if (n >= wordcount)
  859. X            wordcount = n + 1;
  860. X    }
  861. }
  862. X
  863. X
  864. SHAR_EOF
  865. chmod 0644 Response.cc ||
  866. echo 'restore of Response.cc failed'
  867. Wc_c="`wc -c < 'Response.cc'`"
  868. test 2479 -eq "$Wc_c" ||
  869.     echo 'Response.cc: original size 2479, current size' "$Wc_c"
  870. fi
  871. # ============= cursor.cc ==============
  872. if test -f 'cursor.cc' -a X"$1" != X"-c"; then
  873.     echo 'x - skipping cursor.cc (File already exists)'
  874. else
  875. echo 'x - extracting cursor.cc (Text)'
  876. sed 's/^X//' << 'SHAR_EOF' > 'cursor.cc' &&
  877. //
  878. // cursor.cc
  879. //
  880. // (c) Copyright 1993, San Diego State University -- College of Sciences
  881. //       (See the COPYRIGHT file for more Copyright information)
  882. //
  883. // This file deals with the different cursors which may be used
  884. //
  885. #include <xview/xview.h>
  886. #include <xview/svrimage.h>
  887. #include <xview/cursor.h>
  888. #include <xview/notify.h>
  889. X
  890. X
  891. static Cursor        busy_cursor[2];
  892. static Server_image    busy_image[2];
  893. static Cursor        old_cursor;
  894. static int            current_cursor = 0;
  895. X
  896. #define    BLINK_DELAY    200000
  897. X
  898. static unsigned short busy1_bits[] = {
  899. #include "icons/gopher1"
  900. };
  901. X
  902. static unsigned short busy2_bits[] = {
  903. #include "icons/gopher2"
  904. };
  905. X
  906. //***************************************************************************
  907. // void init_cursors()
  908. //
  909. static void init_cursors()
  910. {
  911. X    static int    had_init = FALSE;
  912. X
  913. X    if (had_init)
  914. X        return;
  915. X
  916. X    had_init = TRUE;
  917. X
  918. X    busy_image[0] = (Server_image) xv_create(NULL, SERVER_IMAGE,
  919. X        XV_WIDTH,                    64,
  920. X        XV_HEIGHT,                    64,
  921. X        SERVER_IMAGE_BITS,            busy1_bits,
  922. X        NULL);
  923. X    busy_cursor[0] = (Cursor) xv_create(NULL, CURSOR,
  924. X        CURSOR_IMAGE,                busy_image[0],
  925. X        CURSOR_XHOT,                32,
  926. X        CURSOR_YHOT,                32,
  927. X        NULL);
  928. X    busy_image[1] = (Server_image) xv_create(NULL, SERVER_IMAGE,
  929. X        XV_WIDTH,                    64,
  930. X        XV_HEIGHT,                    64,
  931. X        SERVER_IMAGE_BITS,            busy2_bits,
  932. X        NULL);
  933. X    busy_cursor[1] = (Cursor) xv_create(NULL, CURSOR,
  934. X        CURSOR_IMAGE,                busy_image[1],
  935. X        CURSOR_XHOT,                32,
  936. X        CURSOR_YHOT,                32,
  937. X        NULL);
  938. }
  939. X
  940. X
  941. //***************************************************************************
  942. // Server_image get_gopher(int n)
  943. //
  944. Server_image get_gopher(int n)
  945. {
  946. X    return busy_image[n];
  947. }
  948. X
  949. X
  950. static int    isbusy = FALSE;
  951. X
  952. //***************************************************************************
  953. // static Notify_value blink_cursor(Frame frame, int which)
  954. //
  955. Notify_value blink_cursor(Frame frame, int which)
  956. {
  957. X    which = which;
  958. X
  959. X    current_cursor ^= 1;
  960. X
  961. X    Xv_opaque    sub;
  962. X    int            n = 1;
  963. X    while ((sub = (Xv_opaque) xv_get(frame, FRAME_NTH_SUBWINDOW, n)) != NULL)
  964. X    {
  965. X        xv_set(sub,
  966. X            WIN_CURSOR,                    busy_cursor[current_cursor],
  967. X            NULL);
  968. X        n++;
  969. X    }
  970. X    return (Notify_value) 0;
  971. }
  972. X
  973. X
  974. //***************************************************************************
  975. // void frame_busy(Frame frame)
  976. //
  977. void frame_busy(Frame frame)
  978. {
  979. X    notify_dispatch();
  980. X    if (isbusy)
  981. X        return;
  982. X    isbusy = TRUE;
  983. X    init_cursors();
  984. X    old_cursor = (Cursor) xv_get(frame, WIN_CURSOR);
  985. X    xv_set(frame,
  986. X        FRAME_BUSY,                    TRUE,
  987. X        NULL);
  988. X
  989. X    //
  990. X    // Now go through all sub windows and change their cursor
  991. X    //
  992. X    Xv_opaque    sub;
  993. X    int            n = 1;
  994. X    while ((sub = (Xv_opaque) xv_get(frame, FRAME_NTH_SUBWINDOW, n)) != NULL)
  995. X    {
  996. X        xv_set(sub,
  997. X            WIN_CURSOR,                    busy_cursor[0],
  998. X            NULL);
  999. X        n++;
  1000. X    }
  1001. X
  1002. X    //
  1003. X    // Start the timer to change the cursor icon every once in a while
  1004. X    //
  1005. X    struct itimerval    timer;
  1006. X    timer.it_value.tv_usec = BLINK_DELAY;
  1007. X    timer.it_value.tv_sec = 0;
  1008. X    timer.it_interval.tv_usec = BLINK_DELAY;
  1009. X    timer.it_interval.tv_sec = 0;
  1010. X    notify_set_itimer_func(frame, (Notify_func) blink_cursor, ITIMER_REAL, &timer, NULL);
  1011. }
  1012. X
  1013. X
  1014. //***************************************************************************
  1015. // void frame_unbusy(Frame frame)
  1016. //
  1017. void frame_unbusy(Frame frame)
  1018. {
  1019. X    //
  1020. X    // First stop the interval timer which is blinking the cursor
  1021. X    //
  1022. X    notify_set_itimer_func(frame, NOTIFY_FUNC_NULL, ITIMER_REAL, NULL, NULL);
  1023. X
  1024. X    notify_dispatch();
  1025. X    if (!isbusy)
  1026. X        return;
  1027. X    isbusy = FALSE;
  1028. X    init_cursors();
  1029. X    xv_set(frame,
  1030. X        FRAME_BUSY,                    FALSE,
  1031. X        NULL);
  1032. X
  1033. X    //
  1034. X    // Now go through all sub windows and change their cursor
  1035. X    //
  1036. X    Xv_opaque    sub;
  1037. X    int            n = 1;
  1038. X    while ((sub = (Xv_opaque) xv_get(frame, FRAME_NTH_SUBWINDOW, n)) != NULL)
  1039. X    {
  1040. X        xv_set(sub,
  1041. X            WIN_CURSOR,                    old_cursor,
  1042. X            NULL);
  1043. X        n++;
  1044. X    }
  1045. }
  1046. X
  1047. X
  1048. SHAR_EOF
  1049. chmod 0644 cursor.cc ||
  1050. echo 'restore of cursor.cc failed'
  1051. Wc_c="`wc -c < 'cursor.cc'`"
  1052. test 3627 -eq "$Wc_c" ||
  1053.     echo 'cursor.cc: original size 3627, current size' "$Wc_c"
  1054. fi
  1055. # ============= icons.cc ==============
  1056. if test -f 'icons.cc' -a X"$1" != X"-c"; then
  1057.     echo 'x - skipping icons.cc (File already exists)'
  1058. else
  1059. echo 'x - extracting icons.cc (Text)'
  1060. sed 's/^X//' << 'SHAR_EOF' > 'icons.cc' &&
  1061. //
  1062. // icons.cc
  1063. //
  1064. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1065. //       (See the COPYRIGHT file for more Copyright information)
  1066. //
  1067. // This file defines all the glyphs used in the xvgopher program
  1068. //
  1069. #include <xview/xview.h>
  1070. #include <xview/svrimage.h>
  1071. #include "icons.h"
  1072. X
  1073. static unsigned short bin_bits[] = {
  1074. #include "icons/bin"
  1075. };
  1076. static unsigned short cso_bits[] = {
  1077. #include "icons/cso"
  1078. };
  1079. static unsigned short dir_bits[] = {
  1080. #include "icons/dir"
  1081. };
  1082. static unsigned short doc_bits[] = {
  1083. #include "icons/doc"
  1084. };
  1085. static unsigned short dos_bits[] = {
  1086. #include "icons/dos"
  1087. };
  1088. static unsigned short error_bits[] = {
  1089. #include "icons/error"
  1090. };
  1091. static unsigned short idx_bits[] = {
  1092. #include "icons/idx"
  1093. };
  1094. static unsigned short mac_bits[] = {
  1095. #include "icons/mac"
  1096. };
  1097. static unsigned short tel_bits[] = {
  1098. #include "icons/tel"
  1099. };
  1100. static unsigned short unknown_bits[] = {
  1101. #include "icons/unknown"
  1102. };
  1103. static unsigned short uu_bits[] = {
  1104. #include "icons/uu"
  1105. };
  1106. static unsigned short sound_bits[] = {
  1107. #include "icons/sound"
  1108. };
  1109. static unsigned short image_bits[] = {
  1110. #include "icons/image"
  1111. };
  1112. static unsigned short info_bits[] = {
  1113. #include "icons/info"
  1114. };
  1115. static unsigned short info_dragging_bits[] = {
  1116. #include "icons/info_dragging"
  1117. };
  1118. X
  1119. X
  1120. struct
  1121. {
  1122. X    unsigned char    type;
  1123. X    Server_image    image;
  1124. X    unsigned short    *bits;
  1125. } icons[] =
  1126. {
  1127. X    {'.', NULL, unknown_bits},
  1128. X    {'0', NULL, doc_bits},
  1129. X    {'1', NULL, dir_bits},
  1130. X    {'2', NULL, cso_bits},
  1131. X    {'3', NULL, error_bits},
  1132. X    {'4', NULL, mac_bits},
  1133. X    {'5', NULL, dos_bits},
  1134. X    {'6', NULL, uu_bits},
  1135. X    {'7', NULL, idx_bits},
  1136. X    {'8', NULL, tel_bits},
  1137. X    {'9', NULL, bin_bits},
  1138. X    {'s', NULL, sound_bits},
  1139. X    {'I', NULL, image_bits},
  1140. X    {'g', NULL, image_bits},
  1141. X
  1142. X    //
  1143. X    // The following are images used by other parts of xvgopher.  They are
  1144. X    // identified by characters with the high bit set.
  1145. X    //
  1146. X    {'i' | 0x80, NULL, info_bits},
  1147. X    {'d' | 0x80, NULL, info_dragging_bits},
  1148. X    {'\0', NULL, NULL}
  1149. };
  1150. X
  1151. X
  1152. //***************************************************************************
  1153. // void icon_init()
  1154. //
  1155. void icon_init()
  1156. {
  1157. X    static int    had_init = FALSE;
  1158. X    if (had_init)
  1159. X        return;
  1160. X    had_init = TRUE;
  1161. X
  1162. X    for (int i = 0; icons[i].type; i++)
  1163. X    {
  1164. X        icons[i].image = (Server_image) xv_create(NULL, SERVER_IMAGE,
  1165. X            XV_WIDTH,                    16,
  1166. X            XV_HEIGHT,                    16,
  1167. X            SERVER_IMAGE_BITS,            icons[i].bits,
  1168. X            NULL);
  1169. X    }
  1170. }
  1171. X
  1172. X
  1173. //***************************************************************************
  1174. // Server_image get_image(char type)
  1175. //
  1176. Server_image get_image(char type)
  1177. {
  1178. X    icon_init();
  1179. X
  1180. X    //
  1181. X    // Search through the list of icons to find the right one...
  1182. X    //
  1183. X    for (int i = 0; icons[i].type; i++)
  1184. X    {
  1185. X        if (icons[i].type == (unsigned char) type)
  1186. X            return icons[i].image;
  1187. X    }
  1188. X
  1189. X    //
  1190. X    // Nothing found.  Return the unknown icons
  1191. X    //
  1192. X    return icons[0].image;
  1193. }
  1194. X
  1195. SHAR_EOF
  1196. chmod 0664 icons.cc ||
  1197. echo 'restore of icons.cc failed'
  1198. Wc_c="`wc -c < 'icons.cc'`"
  1199. test 2754 -eq "$Wc_c" ||
  1200.     echo 'icons.cc: original size 2754, current size' "$Wc_c"
  1201. fi
  1202. # ============= main.cc ==============
  1203. if test -f 'main.cc' -a X"$1" != X"-c"; then
  1204.     echo 'x - skipping main.cc (File already exists)'
  1205. else
  1206. echo 'x - extracting main.cc (Text)'
  1207. sed 's/^X//' << 'SHAR_EOF' > 'main.cc' &&
  1208. //
  1209. // main.cc
  1210. //
  1211. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1212. //       (See the COPYRIGHT file for more Copyright information)
  1213. //
  1214. // Main program for xvgopher
  1215. //
  1216. #include "xvgopher.h"
  1217. #include "GWindow.h"
  1218. #include "Preferences.h"
  1219. #include <xview/xview.h>
  1220. X
  1221. X
  1222. Preferences    preferences;
  1223. X
  1224. static int error_proc()
  1225. {
  1226. X    abort();
  1227. X    return XV_OK;
  1228. }
  1229. X
  1230. X
  1231. //***************************************************************************
  1232. // main(int ac, char **av)
  1233. //
  1234. main(int ac, char **av)
  1235. {
  1236. X    char        *server = GOPHER_SERVER;
  1237. X    char        *port = "70";
  1238. X
  1239. X    xv_init(XV_INIT_ARGC_PTR_ARGV,        &ac, av,
  1240. X        XV_ERROR_PROC,            error_proc,
  1241. X        NULL);
  1242. X
  1243. X    switch (ac)
  1244. X    {
  1245. X        case 2:    // A machine was specified
  1246. X            server = av[1];
  1247. X            break;
  1248. X        case 3:    // A machine and port were specified
  1249. X            server = av[1];
  1250. X            port = av[2];
  1251. X            break;
  1252. X    }
  1253. X
  1254. X    Response    *r = new Response("1");
  1255. X    r->set_server(server);
  1256. X    r->set_port(port);
  1257. X    GWindow    *main_window = CreateWindow(r);
  1258. X
  1259. X    if (main_window)
  1260. X        main_window->main_loop();
  1261. X
  1262. X    return 0;
  1263. }
  1264. SHAR_EOF
  1265. chmod 0664 main.cc ||
  1266. echo 'restore of main.cc failed'
  1267. Wc_c="`wc -c < 'main.cc'`"
  1268. test 996 -eq "$Wc_c" ||
  1269.     echo 'main.cc: original size 996, current size' "$Wc_c"
  1270. fi
  1271. # ============= Config.h ==============
  1272. if test -f 'Config.h' -a X"$1" != X"-c"; then
  1273.     echo 'x - skipping Config.h (File already exists)'
  1274. else
  1275. echo 'x - extracting Config.h (Text)'
  1276. sed 's/^X//' << 'SHAR_EOF' > 'Config.h' &&
  1277. //
  1278. // Config.h
  1279. //
  1280. // This class deals with configuration.  All configurable options are kept in this class
  1281. //
  1282. #ifndef    _Config_h_
  1283. #define    _Config_h_
  1284. X
  1285. #include "List.h"
  1286. X
  1287. X
  1288. class Config
  1289. {
  1290. public:
  1291. X    //
  1292. X    // Constructor
  1293. X    //
  1294. X                            Config();
  1295. X
  1296. X    //
  1297. X    // Configuration file access
  1298. X    //
  1299. X    void                    read();
  1300. X    int                        write();
  1301. X
  1302. X    //
  1303. X    // Configuration parameters.  These are directly accessible to make it easier.
  1304. X    //
  1305. X    List                    bookmarks;
  1306. X    String                    server;
  1307. X    int                        port;
  1308. private:
  1309. };
  1310. X
  1311. #endif    _Config_h_
  1312. SHAR_EOF
  1313. chmod 0644 Config.h ||
  1314. echo 'restore of Config.h failed'
  1315. Wc_c="`wc -c < 'Config.h'`"
  1316. test 486 -eq "$Wc_c" ||
  1317.     echo 'Config.h: original size 486, current size' "$Wc_c"
  1318. fi
  1319. # ============= Connection.h ==============
  1320. if test -f 'Connection.h' -a X"$1" != X"-c"; then
  1321.     echo 'x - skipping Connection.h (File already exists)'
  1322. else
  1323. echo 'x - extracting Connection.h (Text)'
  1324. sed 's/^X//' << 'SHAR_EOF' > 'Connection.h' &&
  1325. //
  1326. // Connection.h
  1327. //
  1328. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1329. //       (See the COPYRIGHT file for more Copyright information)
  1330. //
  1331. // This class forms a easy to use interface to the berkeley tcp socket library.
  1332. // All the calls are basically the same, but the parameters do not have any
  1333. // stray _addr or _in mixed in...
  1334. //
  1335. X
  1336. #if !defined(_Connection_h_)
  1337. # define    _Connection_h_
  1338. X
  1339. #include "xvgopher.h"
  1340. #include <stdlib.h>
  1341. #include <string.h>
  1342. #include <sys/types.h>
  1343. #include <sys/socket.h>
  1344. #include <netinet/in.h>
  1345. #include <netdb.h>
  1346. X
  1347. class Connection
  1348. {
  1349. public:
  1350. X    // Constructors & Destructors
  1351. X                    Connection();
  1352. X                    Connection(int socket);
  1353. X                    ~Connection();
  1354. X
  1355. X    // (De)initialization
  1356. X    int                open(int priv = 0);
  1357. X    int                close();
  1358. X
  1359. X    // Port stuff
  1360. X    int                assign_port(int port = 0);
  1361. X    int                assign_port(char *service);
  1362. X    int                get_port();
  1363. X    int                is_privileged();
  1364. X
  1365. X    // Host stuff
  1366. X    int                assign_server(char *name);
  1367. X    int                assign_server(dword addr = INADDR_ANY);
  1368. X
  1369. X    // Connection establishment
  1370. X    int                connect();
  1371. X    Connection        *accept(int priv = 0);
  1372. X    Connection        *accept_privileged();
  1373. X
  1374. X    // Registration things
  1375. X    int                bind();
  1376. X    int                listen(int n = 5);
  1377. X
  1378. X    // IO
  1379. X    int                write(char *buffer, int length);
  1380. X    int                write(char *buffer);
  1381. X    int                read(char *buffer, int length);
  1382. X    char            *read_line(char *buffer, int length);
  1383. X    int                read_partial(char *buffer, int maxlength);
  1384. X    int                bytes_available();
  1385. X    int                get_char();
  1386. X
  1387. X    // Access to socket number
  1388. X    char            *socket_as_string();
  1389. X    int                get_socket();
  1390. X    int                isopen();
  1391. X
  1392. private:
  1393. X    enum
  1394. X    {
  1395. X        BUFFER_SIZE = 1024,
  1396. X    };
  1397. X    int                sock;
  1398. X    struct sockaddr_in    server;
  1399. X    char            buffer[BUFFER_SIZE];
  1400. X    int                pos, pos_max;
  1401. };
  1402. X
  1403. X
  1404. //*************************************************************************
  1405. // inline int Connection::is_privileged()
  1406. // PURPOSE:
  1407. //   Return whether the port is priveleged or not.
  1408. //
  1409. inline int Connection::is_privileged()
  1410. {
  1411. X    return server.sin_port < 1023;
  1412. }
  1413. X
  1414. X
  1415. #endif
  1416. SHAR_EOF
  1417. chmod 0644 Connection.h ||
  1418. echo 'restore of Connection.h failed'
  1419. Wc_c="`wc -c < 'Connection.h'`"
  1420. test 1949 -eq "$Wc_c" ||
  1421.     echo 'Connection.h: original size 1949, current size' "$Wc_c"
  1422. fi
  1423. # ============= GWAbout.h ==============
  1424. if test -f 'GWAbout.h' -a X"$1" != X"-c"; then
  1425.     echo 'x - skipping GWAbout.h (File already exists)'
  1426. else
  1427. echo 'x - extracting GWAbout.h (Text)'
  1428. sed 's/^X//' << 'SHAR_EOF' > 'GWAbout.h' &&
  1429. //
  1430. // GWAbout.h
  1431. //
  1432. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1433. //       (See the COPYRIGHT file for more Copyright information)
  1434. //
  1435. // This class produces a popup window describing the who, what, and where of
  1436. // xvgopher.
  1437. //
  1438. #ifndef    _GWAbout_h_
  1439. #define    _GWAbout_h_
  1440. X
  1441. #include "GWindow.h"
  1442. X
  1443. class GWAbout : public GWindow
  1444. {
  1445. public:
  1446. X                            GWAbout(Frame par);
  1447. X    int                        open(Response *resp);
  1448. private:
  1449. X    static void                done_proc(Frame);
  1450. X    static void                dismiss_proc(Panel_item, Event *);
  1451. X    static Notify_value        panel_events(Xv_window, Event *, Notify_arg, Notify_event_type);
  1452. };
  1453. X
  1454. #endif    _GWAbout_h_
  1455. SHAR_EOF
  1456. chmod 0644 GWAbout.h ||
  1457. echo 'restore of GWAbout.h failed'
  1458. Wc_c="`wc -c < 'GWAbout.h'`"
  1459. test 620 -eq "$Wc_c" ||
  1460.     echo 'GWAbout.h: original size 620, current size' "$Wc_c"
  1461. fi
  1462. # ============= GWBinary.h ==============
  1463. if test -f 'GWBinary.h' -a X"$1" != X"-c"; then
  1464.     echo 'x - skipping GWBinary.h (File already exists)'
  1465. else
  1466. echo 'x - extracting GWBinary.h (Text)'
  1467. sed 's/^X//' << 'SHAR_EOF' > 'GWBinary.h' &&
  1468. //
  1469. // GWBinary.h
  1470. //
  1471. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1472. //       (See the COPYRIGHT file for more Copyright information)
  1473. //
  1474. // This class deals with the getting and saving of ASCII files from
  1475. // a gopher server.
  1476. //
  1477. #ifndef    _GWBinary_h_
  1478. #define    _GWBinary_h_
  1479. X
  1480. #include "GWDownload.h"
  1481. X
  1482. class GWBinary : public GWDownload
  1483. {
  1484. public:
  1485. X                            GWBinary(Frame par);
  1486. };
  1487. X
  1488. #endif    _GWBinary_h_
  1489. SHAR_EOF
  1490. chmod 0644 GWBinary.h ||
  1491. echo 'restore of GWBinary.h failed'
  1492. Wc_c="`wc -c < 'GWBinary.h'`"
  1493. test 417 -eq "$Wc_c" ||
  1494.     echo 'GWBinary.h: original size 417, current size' "$Wc_c"
  1495. fi
  1496. # ============= GWBookmarks.h ==============
  1497. if test -f 'GWBookmarks.h' -a X"$1" != X"-c"; then
  1498.     echo 'x - skipping GWBookmarks.h (File already exists)'
  1499. else
  1500. echo 'x - extracting GWBookmarks.h (Text)'
  1501. sed 's/^X//' << 'SHAR_EOF' > 'GWBookmarks.h' &&
  1502. //
  1503. // GWBookmarks.h
  1504. //
  1505. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1506. //       (See the COPYRIGHT file for more Copyright information)
  1507. //
  1508. // This class deals with bookmarks and the window that displays them.
  1509. //
  1510. #ifndef    _GWBookmarks_h_
  1511. #define    _GWBookmarks_h_
  1512. X
  1513. #include "GWList.h"
  1514. X
  1515. class GWBookmarks : public GWList
  1516. {
  1517. public:
  1518. X    //
  1519. X    // Constructor/Destructor
  1520. X    //
  1521. X                            GWBookmarks(Frame);
  1522. X                            ~GWBookmarks();
  1523. X
  1524. X    //
  1525. X    // Window creation
  1526. X    //
  1527. X    int                        open(Response *resp);
  1528. X    void                    show();
  1529. X
  1530. X    //
  1531. X    // Bookmarks access
  1532. X    //
  1533. X    void                    add(Response *r);
  1534. X
  1535. protected:
  1536. X    void                    row_deselect(int, Response *);
  1537. X    void                    row_select(int, Response *);
  1538. X
  1539. X    void                    read_bookmarks();
  1540. X    void                    write_bookmarks();
  1541. X
  1542. X    static void                remove_bookmark_proc(Menu menu, Menu_item mi);
  1543. X    static void                done_proc(Frame);
  1544. X
  1545. X    //
  1546. X    // The following are used to perform certain specific tasks when creating windows.
  1547. X    // They are split up to make the code more readable and modular
  1548. X    //
  1549. X    void                    modify_list_menu();
  1550. X
  1551. X    Menu_item                bookmark_mi;
  1552. X    Menu_item                show_info_mi;
  1553. };
  1554. X
  1555. extern GWBookmarks    *bookmarks;
  1556. X
  1557. #endif    _GWBookmarks_h_
  1558. SHAR_EOF
  1559. chmod 0644 GWBookmarks.h ||
  1560. echo 'restore of GWBookmarks.h failed'
  1561. Wc_c="`wc -c < 'GWBookmarks.h'`"
  1562. test 1124 -eq "$Wc_c" ||
  1563.     echo 'GWBookmarks.h: original size 1124, current size' "$Wc_c"
  1564. fi
  1565. # ============= GWDirectory.h ==============
  1566. if test -f 'GWDirectory.h' -a X"$1" != X"-c"; then
  1567.     echo 'x - skipping GWDirectory.h (File already exists)'
  1568. else
  1569. echo 'x - extracting GWDirectory.h (Text)'
  1570. sed 's/^X//' << 'SHAR_EOF' > 'GWDirectory.h' &&
  1571. //
  1572. // GWDirectory.h
  1573. //
  1574. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1575. //       (See the COPYRIGHT file for more Copyright information)
  1576. //
  1577. // This class deals with the getting and saving of ASCII files from
  1578. // a gopher server.
  1579. //
  1580. #ifndef    _GWDirectory_h_
  1581. #define    _GWDirectory_h_
  1582. X
  1583. #include "GWList.h"
  1584. X
  1585. class GWDirectory : public GWList
  1586. {
  1587. public:
  1588. X                            GWDirectory(Frame par);
  1589. X    int                        open(Response *resp);
  1590. X    void                    display();
  1591. X
  1592. protected:
  1593. X    //
  1594. X    // Callbacks for the XView interface
  1595. X    //
  1596. #if        USE_SAVE
  1597. X    static void                save_notify(Panel_item item, Event *);
  1598. #endif    USE_SAVE
  1599. X    static void                menu_proc(Menu menu, Menu_item mi);
  1600. X
  1601. X    //
  1602. X    // The next two callbacks are for the menu attached to the scrolling list
  1603. X    //
  1604. X    static void                set_bookmark_proc(Menu menu, Menu_item mi);
  1605. X
  1606. X    void                    row_deselect(int, Response *);
  1607. X    void                    row_select(int, Response *);
  1608. X
  1609. X    //
  1610. X    // Various window thingies that we need to keep track of
  1611. X    //
  1612. X    Menu_item                bookmark_mi;
  1613. X    Menu_item                show_info_mi;
  1614. X
  1615. X    //
  1616. X    // The following are used to perform certain specific tasks when creating windows.
  1617. X    // They are split up to make the code more readable and modular
  1618. X    //
  1619. X    void                    modify_list_menu();
  1620. };
  1621. X
  1622. #endif    _GWDirectory_h_
  1623. SHAR_EOF
  1624. chmod 0664 GWDirectory.h ||
  1625. echo 'restore of GWDirectory.h failed'
  1626. Wc_c="`wc -c < 'GWDirectory.h'`"
  1627. test 1210 -eq "$Wc_c" ||
  1628.     echo 'GWDirectory.h: original size 1210, current size' "$Wc_c"
  1629. fi
  1630. # ============= GWDownload.h ==============
  1631. if test -f 'GWDownload.h' -a X"$1" != X"-c"; then
  1632.     echo 'x - skipping GWDownload.h (File already exists)'
  1633. else
  1634. echo 'x - extracting GWDownload.h (Text)'
  1635. sed 's/^X//' << 'SHAR_EOF' > 'GWDownload.h' &&
  1636. //
  1637. // GWDownload.h
  1638. //
  1639. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1640. //       (See the COPYRIGHT file for more Copyright information)
  1641. //
  1642. // This class deals with the getting and saving of ASCII files from
  1643. // a gopher server.
  1644. //
  1645. #ifndef    _GWDownload_h_
  1646. #define    _GWDownload_h_
  1647. X
  1648. #include "GWindow.h"
  1649. X
  1650. class GWDownload : public GWindow
  1651. {
  1652. public:
  1653. X                            GWDownload(Frame par, int type, char *btn, char *btncmd);
  1654. X                            GWDownload(Frame par, int type);
  1655. X    int                        open(Response *resp);
  1656. X    void                    display();
  1657. X    enum
  1658. X    {
  1659. X        BINARY,
  1660. X        ASCII,
  1661. X    };
  1662. protected:
  1663. X    static void                bin_save_notify(Panel_item, Event *);
  1664. X    static void                bin_cancel_notify(Panel_item, Event *);
  1665. X    static void                bin_other_notify(Panel_item, Event *);
  1666. X    static Panel_setting    bin_text_notify(Panel_item, Event *);
  1667. private:
  1668. X    int                        type;
  1669. X    char                    *button;            // Label of the optional button
  1670. X    char                    *button_command;    // Command to execute when button pressed
  1671. };
  1672. X
  1673. #endif    _GWDownload_h_
  1674. SHAR_EOF
  1675. chmod 0644 GWDownload.h ||
  1676. echo 'restore of GWDownload.h failed'
  1677. Wc_c="`wc -c < 'GWDownload.h'`"
  1678. test 966 -eq "$Wc_c" ||
  1679.     echo 'GWDownload.h: original size 966, current size' "$Wc_c"
  1680. fi
  1681. # ============= GWFile.h ==============
  1682. if test -f 'GWFile.h' -a X"$1" != X"-c"; then
  1683.     echo 'x - skipping GWFile.h (File already exists)'
  1684. else
  1685. echo 'x - extracting GWFile.h (Text)'
  1686. sed 's/^X//' << 'SHAR_EOF' > 'GWFile.h' &&
  1687. //
  1688. // GWFile.h
  1689. //
  1690. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1691. //       (See the COPYRIGHT file for more Copyright information)
  1692. //
  1693. // This class deals with the getting and saving of ASCII files from
  1694. // a gopher server.
  1695. //
  1696. #ifndef    _GWFile_h_
  1697. #define    _GWFile_h_
  1698. X
  1699. #include "GWindow.h"
  1700. X
  1701. class GWFile : public GWindow
  1702. {
  1703. public:
  1704. X                            GWFile(Frame par);
  1705. X    int                        open(Response *resp);
  1706. X    void                    display();
  1707. private:
  1708. X    Textsw                    textsw;
  1709. };
  1710. X
  1711. #endif    _GWFile_h_
  1712. SHAR_EOF
  1713. chmod 0644 GWFile.h ||
  1714. echo 'restore of GWFile.h failed'
  1715. Wc_c="`wc -c < 'GWFile.h'`"
  1716. test 481 -eq "$Wc_c" ||
  1717.     echo 'GWFile.h: original size 481, current size' "$Wc_c"
  1718. fi
  1719. # ============= GWGopher.h ==============
  1720. if test -f 'GWGopher.h' -a X"$1" != X"-c"; then
  1721.     echo 'x - skipping GWGopher.h (File already exists)'
  1722. else
  1723. echo 'x - extracting GWGopher.h (Text)'
  1724. sed 's/^X//' << 'SHAR_EOF' > 'GWGopher.h' &&
  1725. //
  1726. // GWGopher.h
  1727. //
  1728. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1729. //       (See the COPYRIGHT file for more Copyright information)
  1730. //
  1731. // This class creates a popup window which asks for details about a new gopher
  1732. // server.  After this is information is supplied, it will start a new
  1733. // main frame for that gopher server.
  1734. //
  1735. #ifndef    _GWGopher_h_
  1736. #define    _GWGopher_h_
  1737. X
  1738. #include "GWindow.h"
  1739. X
  1740. class GWGopher : public GWindow
  1741. {
  1742. public:
  1743. X                            GWGopher(Frame par);
  1744. X    int                        open(Response *resp);
  1745. private:
  1746. X    static void                start_proc(Panel_item, Event *);
  1747. X
  1748. X    Panel_item                server;
  1749. X    Panel_item                port;
  1750. };
  1751. X
  1752. #endif    _GWGopher_h_
  1753. SHAR_EOF
  1754. chmod 0664 GWGopher.h ||
  1755. echo 'restore of GWGopher.h failed'
  1756. Wc_c="`wc -c < 'GWGopher.h'`"
  1757. test 646 -eq "$Wc_c" ||
  1758.     echo 'GWGopher.h: original size 646, current size' "$Wc_c"
  1759. fi
  1760. # ============= GWImage.h ==============
  1761. if test -f 'GWImage.h' -a X"$1" != X"-c"; then
  1762.     echo 'x - skipping GWImage.h (File already exists)'
  1763. else
  1764. echo 'x - extracting GWImage.h (Text)'
  1765. sed 's/^X//' << 'SHAR_EOF' > 'GWImage.h' &&
  1766. //
  1767. // GWImage.h
  1768. //
  1769. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1770. //       (See the COPYRIGHT file for more Copyright information)
  1771. //
  1772. // This class deals with the getting and saving of ASCII files from
  1773. // a gopher server.
  1774. //
  1775. #ifndef    _GWImage_h_
  1776. #define    _GWImage_h_
  1777. X
  1778. #include "GWDownload.h"
  1779. X
  1780. class GWImage : public GWDownload
  1781. {
  1782. public:
  1783. X                            GWImage(Frame par);
  1784. };
  1785. X
  1786. #endif    _GWImage_h_
  1787. SHAR_EOF
  1788. chmod 0644 GWImage.h ||
  1789. echo 'restore of GWImage.h failed'
  1790. Wc_c="`wc -c < 'GWImage.h'`"
  1791. test 411 -eq "$Wc_c" ||
  1792.     echo 'GWImage.h: original size 411, current size' "$Wc_c"
  1793. fi
  1794. # ============= GWIndex.h ==============
  1795. if test -f 'GWIndex.h' -a X"$1" != X"-c"; then
  1796.     echo 'x - skipping GWIndex.h (File already exists)'
  1797. else
  1798. echo 'x - extracting GWIndex.h (Text)'
  1799. sed 's/^X//' << 'SHAR_EOF' > 'GWIndex.h' &&
  1800. //
  1801. // GWIndex.h
  1802. //
  1803. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1804. //       (See the COPYRIGHT file for more Copyright information)
  1805. //
  1806. // This class deals with the getting and saving of ASCII files from
  1807. // a gopher server.
  1808. //
  1809. #ifndef    _GWIndex_h_
  1810. #define    _GWIndex_h_
  1811. X
  1812. #include "GWindow.h"
  1813. X
  1814. class GWIndex : public GWindow
  1815. {
  1816. public:
  1817. X                            GWIndex(Frame par);
  1818. X    int                        open(Response *resp);
  1819. private:
  1820. X    static Panel_setting    index_notify(Panel_item, Event *);
  1821. };
  1822. X
  1823. #endif    _GWIndex_h_
  1824. SHAR_EOF
  1825. chmod 0644 GWIndex.h ||
  1826. echo 'restore of GWIndex.h failed'
  1827. Wc_c="`wc -c < 'GWIndex.h'`"
  1828. test 503 -eq "$Wc_c" ||
  1829.     echo 'GWIndex.h: original size 503, current size' "$Wc_c"
  1830. fi
  1831. # ============= GWInfo.h ==============
  1832. if test -f 'GWInfo.h' -a X"$1" != X"-c"; then
  1833.     echo 'x - skipping GWInfo.h (File already exists)'
  1834. else
  1835. echo 'x - extracting GWInfo.h (Text)'
  1836. sed 's/^X//' << 'SHAR_EOF' > 'GWInfo.h' &&
  1837. //
  1838. // GWInfo.h
  1839. //
  1840. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1841. //       (See the COPYRIGHT file for more Copyright information)
  1842. //
  1843. // This class defines a window which shows information about an item.
  1844. // The only things which is passed to this window is a Response.  Everything can
  1845. // be deduced from there.
  1846. //
  1847. #ifndef    _GWInfo_h_
  1848. #define    _GWInfo_h_
  1849. X
  1850. #include "xvgopher.h"
  1851. #include "GWindow.h"
  1852. #include "Response.h"
  1853. X
  1854. class GWInfo : public GWindow
  1855. {
  1856. public:
  1857. X                            GWInfo(Frame par);
  1858. X    int                        open(Response *);
  1859. private:
  1860. };
  1861. X
  1862. #endif    _GWInfo_h_
  1863. SHAR_EOF
  1864. chmod 0644 GWInfo.h ||
  1865. echo 'restore of GWInfo.h failed'
  1866. Wc_c="`wc -c < 'GWInfo.h'`"
  1867. test 569 -eq "$Wc_c" ||
  1868.     echo 'GWInfo.h: original size 569, current size' "$Wc_c"
  1869. fi
  1870. # ============= GWList.h ==============
  1871. if test -f 'GWList.h' -a X"$1" != X"-c"; then
  1872.     echo 'x - skipping GWList.h (File already exists)'
  1873. else
  1874. echo 'x - extracting GWList.h (Text)'
  1875. sed 's/^X//' << 'SHAR_EOF' > 'GWList.h' &&
  1876. //
  1877. // GWList.h
  1878. //
  1879. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1880. //       (See the COPYRIGHT file for more Copyright information)
  1881. //
  1882. // This class is a base class for any window which displays a list of gopher items.
  1883. //
  1884. #ifndef    _GWList_h_
  1885. #define    _GWList_h_
  1886. X
  1887. #include "GWindow.h"
  1888. #include "cursor.h"
  1889. #include "icons.h"
  1890. X
  1891. class GWList : public GWindow
  1892. {
  1893. public:
  1894. X    //
  1895. X    // Constructor
  1896. X    //
  1897. X                            GWList();
  1898. X
  1899. X    //
  1900. X    // Window creation
  1901. X    //
  1902. X    int                        open(Response *resp);
  1903. X
  1904. protected:
  1905. X    //
  1906. X    // Data members needed to keep track of the windowing stuff
  1907. X    //
  1908. X    Panel_item                dir_list;
  1909. X    int                        current_selected;
  1910. X
  1911. X    //
  1912. X    // Callback routines from XView.
  1913. X    //
  1914. X    static void                frame_event(Xv_Window, Event *, Notify_arg);
  1915. X    static void                list_notify(Panel_item, char *, caddr_t, Panel_list_op, Event *, int);
  1916. X    static void                show_item_info_proc(Menu menu, Menu_item mi);
  1917. X
  1918. X    //
  1919. X    // Members which are supposed to be overridden.
  1920. X    //
  1921. X    virtual void            row_deselect(int, Response *);
  1922. X    virtual void            row_select(int, Response *);
  1923. X
  1924. X    //
  1925. X    // Utility routines
  1926. X    //
  1927. X    void                    assign_icon(Frame);
  1928. };
  1929. X
  1930. #endif    _GWList_h_
  1931. SHAR_EOF
  1932. chmod 0664 GWList.h ||
  1933. echo 'restore of GWList.h failed'
  1934. Wc_c="`wc -c < 'GWList.h'`"
  1935. test 1107 -eq "$Wc_c" ||
  1936.     echo 'GWList.h: original size 1107, current size' "$Wc_c"
  1937. fi
  1938. # ============= GWPref.h ==============
  1939. if test -f 'GWPref.h' -a X"$1" != X"-c"; then
  1940.     echo 'x - skipping GWPref.h (File already exists)'
  1941. else
  1942. echo 'x - extracting GWPref.h (Text)'
  1943. sed 's/^X//' << 'SHAR_EOF' > 'GWPref.h' &&
  1944. //
  1945. // GWPref.h
  1946. //
  1947. // (c) Copyright 1993, San Diego State University -- College of Sciences
  1948. //       (See the COPYRIGHT file for more Copyright information)
  1949. //
  1950. // This class deals with the interface between the preferences and the window which allows
  1951. // the preferences to be changed.
  1952. //
  1953. #ifndef    _GWPref_h_
  1954. #define    _GWPref_h_
  1955. X
  1956. #include "GWindow.h"
  1957. X
  1958. class GWPref : public GWindow
  1959. {
  1960. public:
  1961. X    //
  1962. X    // Constructor
  1963. X    //
  1964. X                            GWPref(Frame);
  1965. X                            ~GWPref();
  1966. X    int                        open(Response *);
  1967. X    void                    show();
  1968. private:
  1969. X    //
  1970. X    // Remember where items are so we can reference them!
  1971. X    //
  1972. X    Panel_item                choices;
  1973. X    Panel_item                play;
  1974. X    Panel_item                image;
  1975. X    Panel_item                print;
  1976. X    Panel_item                mail;
  1977. X    Panel_item                telnet;
  1978. X
  1979. X    //
  1980. X    // Call back routines
  1981. X    //
  1982. X    static void                done_proc(Frame);
  1983. X    static void                apply(Panel_item, Event *);
  1984. };
  1985. X
  1986. X
  1987. extern GWPref    *gwpref;
  1988. X
  1989. #endif    _GWPref_h_
  1990. SHAR_EOF
  1991. chmod 0644 GWPref.h ||
  1992. echo 'restore of GWPref.h failed'
  1993. Wc_c="`wc -c < 'GWPref.h'`"
  1994. test 860 -eq "$Wc_c" ||
  1995.     echo 'GWPref.h: original size 860, current size' "$Wc_c"
  1996. fi
  1997. # ============= GWSound.h ==============
  1998. if test -f 'GWSound.h' -a X"$1" != X"-c"; then
  1999.     echo 'x - skipping GWSound.h (File already exists)'
  2000. else
  2001. echo 'x - extracting GWSound.h (Text)'
  2002. sed 's/^X//' << 'SHAR_EOF' > 'GWSound.h' &&
  2003. //
  2004. // GWSound.h
  2005. //
  2006. // (c) Copyright 1993, San Diego State University -- College of Sciences
  2007. //       (See the COPYRIGHT file for more Copyright information)
  2008. //
  2009. // This class deals with the getting and saving of ASCII files from
  2010. // a gopher server.
  2011. //
  2012. #ifndef    _GWSound_h_
  2013. #define    _GWSound_h_
  2014. X
  2015. #include "GWDownload.h"
  2016. X
  2017. class GWSound : public GWDownload
  2018. {
  2019. public:
  2020. X                            GWSound(Frame par);
  2021. };
  2022. X
  2023. #endif    _GWSound_h_
  2024. SHAR_EOF
  2025. chmod 0644 GWSound.h ||
  2026. echo 'restore of GWSound.h failed'
  2027. Wc_c="`wc -c < 'GWSound.h'`"
  2028. test 411 -eq "$Wc_c" ||
  2029.     echo 'GWSound.h: original size 411, current size' "$Wc_c"
  2030. fi
  2031. # ============= GWTelnet.h ==============
  2032. if test -f 'GWTelnet.h' -a X"$1" != X"-c"; then
  2033.     echo 'x - skipping GWTelnet.h (File already exists)'
  2034. else
  2035. echo 'x - extracting GWTelnet.h (Text)'
  2036. sed 's/^X//' << 'SHAR_EOF' > 'GWTelnet.h' &&
  2037. //
  2038. // GWTelnet.h
  2039. //
  2040. // (c) Copyright 1993, San Diego State University -- College of Sciences
  2041. //       (See the COPYRIGHT file for more Copyright information)
  2042. //
  2043. // This class deals with the getting and saving of ASCII files from
  2044. // a gopher server.
  2045. //
  2046. #ifndef    _GWTelnet_h_
  2047. #define    _GWTelnet_h_
  2048. X
  2049. #include "GWindow.h"
  2050. X
  2051. class GWTelnet : public GWindow
  2052. {
  2053. public:
  2054. X                            GWTelnet(Frame par);
  2055. X    virtual int                open(Response *resp);
  2056. private:
  2057. };
  2058. X
  2059. #endif    _GWTelnet_h_
  2060. SHAR_EOF
  2061. chmod 0644 GWTelnet.h ||
  2062. echo 'restore of GWTelnet.h failed'
  2063. Wc_c="`wc -c < 'GWTelnet.h'`"
  2064. test 458 -eq "$Wc_c" ||
  2065.     echo 'GWTelnet.h: original size 458, current size' "$Wc_c"
  2066. fi
  2067. # ============= GWindow.h ==============
  2068. if test -f 'GWindow.h' -a X"$1" != X"-c"; then
  2069.     echo 'x - skipping GWindow.h (File already exists)'
  2070. else
  2071. echo 'x - extracting GWindow.h (Text)'
  2072. sed 's/^X//' << 'SHAR_EOF' > 'GWindow.h' &&
  2073. //
  2074. // GWindow.h
  2075. //
  2076. // (c) Copyright 1993, San Diego State University -- College of Sciences
  2077. //       (See the COPYRIGHT file for more Copyright information)
  2078. //
  2079. // The Window class does everything that needs to be done concerning
  2080. // gopher and XView.
  2081. //
  2082. #ifndef    _GWindow_h_
  2083. #define    _GWindow_h_
  2084. X
  2085. #include "Gopher.h"
  2086. #include "Response.h"
  2087. #include <xview/xview.h>
  2088. #include <xview/frame.h>
  2089. #include <xview/panel.h>
  2090. #include <xview/textsw.h>
  2091. X
  2092. #define    WINDOW_WIDTH        536
  2093. #define    WINDOW_HEIGHT        332
  2094. X
  2095. class GWindow
  2096. {
  2097. public:
  2098. X    //
  2099. X    // Constructors/Destructors
  2100. X    //
  2101. X                            GWindow();
  2102. X                            ~GWindow();
  2103. X
  2104. X    //
  2105. X    // Different ways of opening new windows
  2106. X    //
  2107. X    friend GWindow            *CreateWindow(Response *resp, Frame parent = NULL);
  2108. X    virtual int                open(Response *resp);
  2109. X
  2110. X    //
  2111. X    // These are callbacks which are to notify us of finished business.
  2112. X    //
  2113. X
  2114. X    //
  2115. X    // The program's main loop is actuall in this class
  2116. X    //
  2117. X    void                    main_loop();
  2118. X
  2119. X    virtual void            display();
  2120. X    void                    status(char *str);
  2121. X
  2122. X    //
  2123. X    // Some notifications
  2124. X    //
  2125. X    void                    nothing_found();
  2126. X    void                    list_full();
  2127. X
  2128. protected:
  2129. X    //
  2130. X    // We need to remember things about the windows:
  2131. X    //
  2132. X    Frame                    frame;
  2133. X    Panel                    panel;
  2134. X    Frame                    parent;
  2135. X
  2136. X    //
  2137. X    // The following two variables are used to keep track of window locations.
  2138. X    // They are static since all instances of this class need to have access to the
  2139. X    // same variables.
  2140. X    //
  2141. X    static int                next_x;
  2142. X    static int                next_y;
  2143. X
  2144. X    //
  2145. X    // Internal routines used for the windowing system
  2146. X    //
  2147. X    Gopher                    *gopher;
  2148. X
  2149. X    //
  2150. X    // The complete gopher information used to create this window
  2151. X    //
  2152. X    Response                *info;
  2153. X
  2154. X    //
  2155. X    // Routine to determine the next window location
  2156. X    //
  2157. X    void                    compute_location(int width, int height);
  2158. X
  2159. X    //
  2160. X    // Callback for windows
  2161. X    //
  2162. X    static void                done_proc(Frame frame);
  2163. X    static void                quit_proc(Frame frame, Event *event);
  2164. X
  2165. X    //
  2166. X    // The quit/dismiss button that every window has...
  2167. X    //
  2168. X    Panel_item                dir_quit;
  2169. };
  2170. X
  2171. #endif    _GWindow_h_
  2172. X
  2173. SHAR_EOF
  2174. chmod 0664 GWindow.h ||
  2175. echo 'restore of GWindow.h failed'
  2176. Wc_c="`wc -c < 'GWindow.h'`"
  2177. test 1931 -eq "$Wc_c" ||
  2178.     echo 'GWindow.h: original size 1931, current size' "$Wc_c"
  2179. fi
  2180. # ============= Gopher.h ==============
  2181. if test -f 'Gopher.h' -a X"$1" != X"-c"; then
  2182.     echo 'x - skipping Gopher.h (File already exists)'
  2183. else
  2184. echo 'x - extracting Gopher.h (Text)'
  2185. sed 's/^X//' << 'SHAR_EOF' > 'Gopher.h' &&
  2186. //
  2187. // Gopher.h
  2188. //
  2189. // (c) Copyright 1993, San Diego State University -- College of Sciences
  2190. //       (See the COPYRIGHT file for more Copyright information)
  2191. //
  2192. // This class implements an interface to a gopher server
  2193. //
  2194. #ifndef    _Gopher_h_
  2195. #define    _Gopher_h_
  2196. X
  2197. #include "List.h"
  2198. X
  2199. //
  2200. // The following defines are used to determine what kind of data the
  2201. // server is providing
  2202. //
  2203. X
  2204. class Gopher
  2205. {
  2206. public:
  2207. X    //
  2208. X    // Constructors/Destructor
  2209. X    //
  2210. X                            Gopher(class GWindow *gwin);
  2211. X                            Gopher(char *server, int port, class GWindow *gwin);
  2212. X                            ~Gopher();
  2213. X
  2214. X    int                        open(char *server, int port);
  2215. X
  2216. X    //
  2217. X    // Data retrieval
  2218. X    //
  2219. X    int                        read(char type, char *str);
  2220. X    void                    start_get();
  2221. X    char                    *get_next();
  2222. X    void                    read_list();
  2223. X    void                    read_ascii();
  2224. X    void                    read_binary();
  2225. X
  2226. X    //
  2227. X    // Data types can be of several types.  The data types determine
  2228. X    // where the actual data is kept.
  2229. X    //
  2230. X    typedef enum
  2231. X    {
  2232. X        TYPE_LIST,
  2233. X        TYPE_ASCII,
  2234. X        TYPE_BINARY,
  2235. X        TYPE_SOUND,
  2236. X        TYPE_IMAGE,
  2237. X    } DataType;
  2238. X
  2239. X    //
  2240. X    // To let others know what kind of data we are looking at we
  2241. X    // have the following variable:
  2242. X    //
  2243. X    DataType                datatype;
  2244. X
  2245. X    char                    filename[100];
  2246. X
  2247. private:
  2248. X    class Connection        *connection;    // Connection with gopher server
  2249. X    class GWindow            *gwindow;        // The window that belongs to us
  2250. X
  2251. X    List                    list;
  2252. X    int                        fd;
  2253. X    int                        length;            // To keep track of file size
  2254. X
  2255. X    //
  2256. X    // Callback routines.  (They need to be static!!!)
  2257. X    //
  2258. X    static void                read_list_proc(Gopher *gopher, int fd);
  2259. X    static void                read_ascii_proc(Gopher *gopher, int fd);
  2260. X    static void                read_binary_proc(Gopher *gopher, int fd);
  2261. };
  2262. X
  2263. #endif    _Gopher_h_
  2264. SHAR_EOF
  2265. chmod 0644 Gopher.h ||
  2266. echo 'restore of Gopher.h failed'
  2267. Wc_c="`wc -c < 'Gopher.h'`"
  2268. test 1608 -eq "$Wc_c" ||
  2269.     echo 'Gopher.h: original size 1608, current size' "$Wc_c"
  2270. fi
  2271. # ============= List.h ==============
  2272. if test -f 'List.h' -a X"$1" != X"-c"; then
  2273.     echo 'x - skipping List.h (File already exists)'
  2274. else
  2275. echo 'x - extracting List.h (Text)'
  2276. sed 's/^X//' << 'SHAR_EOF' > 'List.h' &&
  2277. //
  2278. // List.h
  2279. //
  2280. // (c) Copyright 1993, San Diego State University -- College of Sciences
  2281. //       (See the COPYRIGHT file for more Copyright information)
  2282. //
  2283. // This class implements a linked list of objects.  It itself is also an
  2284. // object
  2285. //
  2286. #ifndef    _List_h_
  2287. #define    _List_h_
  2288. X
  2289. #include "Object.h"
  2290. X
  2291. class List : public Object
  2292. {
  2293. public:
  2294. X    //
  2295. X    // Constructors/Destructor
  2296. X    //
  2297. X                            List();
  2298. //                            List(List &list);
  2299. X    virtual                    ~List();
  2300. X
  2301. X    //
  2302. X    // List access
  2303. X    //
  2304. X    void                    add(Object *obj);
  2305. X    void                    detach(Object *obj);
  2306. X
  2307. X    //
  2308. X    // List traversal
  2309. X    //
  2310. X    void                    start_get();
  2311. X    Object                    *get_next();
  2312. X
  2313. protected:
  2314. X    //
  2315. X    // These variables are to keep track of the linked list
  2316. X    //
  2317. X    Object                    *first;
  2318. X    Object                    *last;
  2319. X    Object                    *current;
  2320. X
  2321. X    int                        size;
  2322. };
  2323. X
  2324. #endif    _List_h_
  2325. SHAR_EOF
  2326. chmod 0644 List.h ||
  2327. echo 'restore of List.h failed'
  2328. Wc_c="`wc -c < 'List.h'`"
  2329. test 771 -eq "$Wc_c" ||
  2330.     echo 'List.h: original size 771, current size' "$Wc_c"
  2331. fi
  2332. true || echo 'restore of Object.h failed'
  2333. echo End of part 3, continue with part 4
  2334. exit 0
  2335.